package com.bank.util;
import javax.swing.*;
import java.awt.*;

public class UIUtils {

    // 显示消息对话框
    public static void showMessageDialog(Component parent, String message) {
        JOptionPane.showMessageDialog(parent, message, "信息", JOptionPane.INFORMATION_MESSAGE);
    }

    // 显示错误对话框
    public static void showErrorMessageDialog(Component parent, String message) {
        JOptionPane.showMessageDialog(parent, message, "错误", JOptionPane.ERROR_MESSAGE);
    }

    // 显示确认对话框
    public static int showConfirmDialog(Component parent, String message) {
        return JOptionPane.showConfirmDialog(parent, message, "确认", JOptionPane.YES_NO_OPTION);
    }

    // 创建输入框面板
    public static JPanel createInputPanel(String labelText, JTextField inputField) {
        JPanel panel = new JPanel(new GridLayout(1, 2));
        panel.add(new JLabel(labelText));
        panel.add(inputField);
        return panel;
    }

    // 创建按钮面板
    public static JPanel createButtonPanel(JButton... buttons) {
        JPanel panel = new JPanel();
        for (JButton button : buttons) {
            panel.add(button);
        }
        return panel;
    }

    // 创建表格面板
    public static JPanel createTablePanel(JTable table) {
        JPanel panel = new JPanel(new BorderLayout());
        panel.add(new JScrollPane(table), BorderLayout.CENTER);
        return panel;
    }
}
